:root {
  --popups-margin: 4px;
}

@keyframes leftToRight {
  0%,
  25% {
    transform: translateX(0%);
    left: 0%;
  }
  75%,
  100% {
    transform: translateX(-100%);
    left: 100%;
  }
}

%actionable-button {
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;

  &:hover {
    background-color: rgba(var(--config-accent-color-rgb), 0.2);
  }

  &:active {
    background-color: rgba(var(--config-accent-color-rgb), 0.4);
  }
}

%flex-centered {
  display: flex;
  align-items: center;
  justify-content: center;
}

%list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

%overflowable-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

%hidden-scroll {
  ::-webkit-scrollbar {
    height: 0;
    width: 0;
  }
}

%section-title {
  font-size: 0.8rem;
  line-height: 1.2em;
  font-weight: 600;
  color: var(--color-gray-600);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

%popup {
  @extend %list;
  gap: 10px;
  margin: var(--popups-margin);
  width: 300px;
  max-height: calc(100vh - var(--config-height) - (var(--popups-margin) * 2));
  padding: 10px;
  box-shadow: 0 0 10px 10px #0001;
  border-radius: 10px;

  .bg-layer-1 {
    background-color: var(--color-gray-50);
    border-radius: 10px;
  }
}

.chevron {
  transition: transform 0.3s ease-in-out;
  &.chevron-active {
    transform: rotate(180deg);
  }
}

* {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background-color: transparent;
  }

  ::-webkit-scrollbar-thumb {
    background-color: var(--color-gray-400);
    border-radius: 8px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background-color: var(--color-gray-500);
  }
}

#root {
  font-size: 0.8rem;
  font-weight: 500;
}

@keyframes PopupBaseAnimation {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.keyboard-selector-open,
.notification-open,
.settings-open,
.calendar-open,
.tray-open,
.wlan-open,
.media-open,
.media-notifier-open,
.ft-bar-item-context-menu-open,
.ft-bar-context-menu-open,
.userhome-open,
.userhome-quicksettings-open {
  animation: PopupBaseAnimation 0.2s linear forwards;
}

.keyboard-selector-close,
.notification-close,
.settings-close,
.calendar-close,
.tray-close,
.wlan-close,
.media-close,
.media-notifier-close,
.ft-bar-item-context-menu-close,
.ft-bar-context-menu-close,
.userhome-close,
.userhome-quicksettings-close {
  animation: PopupBaseAnimation 0.2s linear forwards;
  animation-direction: reverse;
}

.ft-bar {
  transition: background-color 0.2s linear;
  color: var(--color-focused-app-foreground, var(--color-persist-gray-100));
  // we skip the first layer, to avoid break user themes, as before v2.2 the first layer was a noise layer
  .bg-layer-2 {
    transition: background-color 0.2s linear;
    background-color: var(--color-focused-app-background, var(--color-persist-gray-900));
  }
}

.ft-bar-item {
  .workspace-dot {
    width: 6px;
    height: 6px;
    border-radius: 3px;
    background-color: var(--color-focused-app-foreground, var(--color-persist-gray-100));
    transition-property: width, border-radius, background-color;
    transition-duration: 200ms;
    transition-timing-function: ease-out;

    &:not(:last-child) {
      margin-right: 12px;
    }

    &.workspace-dot-active {
      width: 18px;
      background-color: var(--config-accent-color);
    }
  }
}

.ft-bar-item-context-menu-container,
.tb-context-menu-container {
  min-width: 160px;

  .bg-layer-1 {
    background-color: var(--color-gray-100);
    border-radius: 10px;
  }
}

.ft-bar-item-clickable {
  padding: 1px 4px;
  border-radius: 6px;

  &:hover {
    backdrop-filter: brightness(3);
  }
}

.ft-bar-item-active {
  color: var(--config-accent-color);
}

.ft-bar-item-content {
  position: relative;
}

.ft-bar-item-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(25%, -25%);
  background-color: var(--config-accent-color);
  color: #efefef;
  height: 12px;
  min-width: 12px;
  font-size: 10px;
  border-radius: 8px;
}

.fast-settings {
  padding: 12px 16px;
  margin: var(--popups-margin);

  .fast-settings-bg-layer-1 {
    background-color: var(--color-gray-50);
    border-radius: 10px;
  }
}

.fast-settings-power {
  display: flex;
  gap: 6px;

  .fast-settings-item-button {
    @extend %actionable-button, %flex-centered;
    flex: 1;
    border: 1px solid var(--color-gray-600);
    border-radius: 8px;
    padding: 8px 12px;
  }
}

.tray {
  margin: var(--popups-margin);

  .tray-bg-layer-1 {
    background-color: var(--color-gray-50);
    border-radius: 10px;
    box-shadow: 0 0 10px 10px #0001;
  }
}

.tray-list {
  padding: 10px;
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  gap: 4px;
}

.tray-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  padding: 8px;
  gap: 6px;
  height: min-content;

  &:hover {
    background-color: rgba(var(--config-accent-color-rgb), 0.2);
  }

  .tray-item-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;

    .tray-item-icon {
      height: 1rem;
      object-fit: contain;
    }
  }

  .tray-item-label {
    font-size: 0.7rem;
    font-weight: 600;
  }

  .tray-item-label-tooltip {
    padding: 0 40px;
  }
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.wlan-selector {
  @extend %popup;

  .wlan-selector-title {
    @extend %section-title;
  }

  .wlan-selector-refresh {
    @extend %actionable-button;
    .slu-icon {
      color: var(--color-gray-900);
      animation: rotate 1s linear infinite;
    }
  }

  .wlan-selector-entries {
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-gray-300);
    overflow-y: auto;
    max-height: 30vh;

    .wlan-selector-empty {
      font-style: italic;
    }

    .wlan-entry {
      min-height: min-content;
      padding: 12px 10px;
      border-radius: 8px;
      gap: 10px;

      &:hover {
        background-color: var(--color-gray-200);
      }

      &.wlan-entry-selected {
        background-color: rgba(var(--config-accent-color-rgb), 0.2);
      }

      .wlan-entry-info {
        font-weight: 600;
        gap: 8px;

        .wlan-entry-info-ssid {
          flex: 1;
          color: var(--color-gray-800);
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }

        .wlan-entry-info-channel {
          font-size: 0.5rem;
          color: var(--color-gray-600);
          border: 1px solid var(--color-gray-600);
          border-radius: 4px;
          padding: 2px 4px;
        }
      }
    }
  }

  .wlan-selector-footer {
    .wlan-selector-footer-button {
      @extend %actionable-button;
    }
  }
}

.media-control {
  margin: var(--popups-margin);
  width: 300px;
  padding: 10px;

  .bg-layer-1 {
    background-color: var(--color-gray-50);
    border-radius: 10px;
  }

  .media-device-group {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 20vh;
    gap: 6px;

    .media-device {
      display: grid;
      align-items: center;
      grid-template-columns: 50px 1fr 50px;
      gap: 8px;

      .media-device-action {
        @extend %actionable-button;
        justify-content: center;
      }
    }
  }

  .media-device-header {
    display: flex;
    gap: 6px;
    align-items: center;
    padding-bottom: 10px;

    .media-device-back {
      @extend %actionable-button;
    }

    .media-device-title {
      flex: 1;
      @extend %overflowable-text;
    }
  }

  .media-device-mixer {
    @extend %list;
    padding-right: 10px;

    .media-device-mixer-entry-icon {
      height: 100%;
      display: grid;
      align-items: center;
      grid-template-columns: 1fr 18px;
      gap: 4px;
    }
  }

  .media-device-footer {
    padding-top: 10px;

    .media-device-footer-button {
      @extend %actionable-button;
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--color-gray-600);
    }
  }
}

.media-notifier {
  margin: var(--popups-margin);
  width: 240px;
  padding: 6px 24px 6px 6px;

  .bg-layer-1 {
    background-color: var(--color-gray-50);
    border-radius: 10px;
  }
}

.media-control-volume {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  height: 30px;
  align-items: center;
  gap: 4px;

  .media-control-volume-action {
    @extend %actionable-button;
    height: 30px;
    width: 50px;
    justify-content: center;
  }
}

.fast-settings-label,
.media-control-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-gray-600);
  margin-bottom: 4px;
  display: block;
  width: 100%;

  &:not(:first-of-type) {
    margin-top: 10px;
    padding-top: 4px;
    border-top: solid 1px var(--color-gray-300);
  }
}

.media-device {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--color-gray-700);
}

.media-control-session-list {
  display: flex;
  flex-direction: column;
  margin-top: 6px;
  gap: 4px;
}

.media-session {
  display: grid;
  grid-template-columns: 80px 1fr;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  padding: 8px;
  gap: 8px;
  height: min-content;
}

.media-session-thumbnail-container {
  position: relative;
  z-index: 2;
  width: 100%;
}

.media-session-app-icon {
  position: absolute;
  z-index: 3;
  width: 25%;
  aspect-ratio: 1/1;
  right: 5%;
  bottom: 5%;
  object-fit: contain;
}

.media-session-thumbnail {
  border-radius: 8px;
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: contain;
  background: #0004;
}

.media-session-blurred-thumbnail {
  filter: blur(15px) brightness(125%) contrast(125%);
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.media-session-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
}

.media-session-title,
.media-session-author {
  position: relative;
  align-self: flex-start;
  font-size: 0.7rem;
  text-align: center;
  min-width: 100%;
  animation: leftToRight 5s infinite alternate ease-in-out;
}

.media-session-title {
  font-weight: 600;
  font-size: 1rem;
}

.media-session-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.notifications {
  @extend %popup;

  .notifications-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    .notifications-clear-button {
      @extend %actionable-button;
      font-weight: 600;
      font-size: 0.8rem;
    }
  }

  .notifications-body {
    @extend %list;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 5px 10px;
    margin: 0 -10px;
  }

  .notifications-footer {
    .notifications-settings-button {
      @extend %actionable-button;
      font-weight: 600;
      font-size: 0.8rem;
    }
  }

  .notifications-empty {
    @extend %flex-centered;
    color: var(--color-gray-500);
    font-weight: 600;
    font-size: 0.8rem;
  }
}

@keyframes text-highlight {
  0% {
    color: var(--color-gray-600);
  }
  66% {
    color: var(--config-accent-color);
  }
  100% {
    color: var(--color-gray-600);
  }
}

.notification-arrival {
  @extend %list;
  margin: var(--popups-margin);
  width: 350px;
  max-height: calc(100vh - var(--config-height) - (var(--popups-margin) * 2));

  .notification-header-info {
    animation: text-highlight 5s ease-in-out infinite;
  }

  &:not(:has(.notification)) {
    display: none;
  }
}

.notification {
  border-radius: 12px;
  background-color: var(--color-gray-100);
  box-shadow: 0px 2px 3px 0px rgba(0, 0, 0, 0.4);
  padding: 10px;
  transition: scale 0.1s ease-in-out;

  &:active:not(:has(.notification-header-close:active, .notification-action:active)) {
    scale: 0.9;
  }

  .notification-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 5px;
    border-bottom: solid 1px var(--color-gray-300);
    margin-bottom: 5px;

    .notification-header-info {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 0.8rem;
      color: var(--color-gray-800);

      .notification-icon {
        width: 1.5em;
      }
    }

    .notification-header-close {
      @extend %actionable-button;
    }
  }

  .notification-body {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;

    .notification-body-logo-image {
      grid-column: 1 / 2;
      grid-row: 1 / 2;
      width: 3rem;
      height: 3rem;
    }

    .notification-body-content {
      word-break: break-word;
      overflow: hidden;
      grid-column: 2 / 3;
      grid-row: 1 / 2;
    }

    .notification-body-hero-image {
      grid-column: 1 / 3;
      grid-row: 2 / 3;
      width: 100%;
      max-height: 300px;
      object-fit: cover;
    }
  }

  .notification-actions {
    display: flex;

    .notification-action {
      @extend %actionable-button;
      margin-top: 10px;
      flex: 1;
      justify-content: center;
      border: 1px solid var(--color-gray-600);
    }
  }
}

.calendar-container {
  margin: var(--popups-margin);
  width: 350px;
  padding: 10px;

  .bg-layer-1 {
    background-color: var(--color-gray-50);
    border-radius: 12px;
  }

  .calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;

    .calendar-date {
      font-size: 1.2em;
      text-transform: capitalize;
      transition: 0.2s ease-in;
      transition-property: color, background-color;
      border-radius: 4px;
      padding: 0 4px;

      &:hover {
        color: var(--config-accent-color);
        background-color: var(--color-gray-200);
      }
    }

    .calendar-actions {
      display: flex;
      align-items: center;
      gap: 2px;

      .calendar-navigator {
        font-size: 1.2em;
        padding: 3px 8px;
        cursor: pointer;
        background-color: transparent;
        transition: 0.2s ease-in;
        transition-property: color, background-color;
        border-radius: 4px;

        &:hover {
          color: var(--config-accent-color);
          background-color: var(--color-gray-200);
        }
      }
    }
  }

  .calendar-cell-value {
    --margin: 4px;
    position: relative;
    transition: background-color 0.2s ease-in;
    border-radius: 4px;
    width: calc(100% - (var(--margin) * 2));
    height: calc(100% - (var(--margin) * 2));
    display: flex;
    justify-content: center;
    align-items: center;
    margin: var(--margin);

    &.calendar-cell-selected {
      background-color: var(--color-gray-100);
      color: var(--config-accent-color);
    }

    &:hover {
      background-color: var(--color-gray-200);
    }

    &.calendar-cell-today {
      background-color: rgba(var(--config-accent-color-rgb), 0.2);
    }

    &.calendar-cell-month {
      text-transform: capitalize;
    }
  }
}

.userhome {
  @extend %list;
  margin: var(--popups-margin);
  width: 300px;
  box-shadow: 0 0 10px 10px #0001;
  padding: 10px;
  max-height: calc(99vh - var(--config-height));

  .userhome-bg-layer-1 {
    background-color: var(--color-gray-50);
    border-radius: 10px;
  }

  .userhome-label {
    @extend %section-title;
  }

  .userhome-file {
    @extend %actionable-button;
    display: grid;
    grid-template-columns: 1rem 1fr min-content;
    align-items: center;
    gap: 4px;

    .userhome-file-icon {
      object-fit: contain;
    }

    .userhome-file-label {
      @extend %overflowable-text;
    }

    .userhome-file-date {
      @extend %overflowable-text;
      color: var(--color-gray-600);
      font-size: 0.6rem;
    }
  }

  .userhome-empty-list {
    @extend %flex-centered;
    padding: 20px;
    font-style: italic;
    font-weight: 600;
    color: var(--color-gray-600);
    font-size: 0.8rem;
  }

  .userhome-list-extender {
    @extend %actionable-button;
    white-space: nowrap;
    width: min-content;
    font-size: 0.6rem;
    color: var(--color-gray-600);
  }

  .userhome-profile-container {
    display: flex;
    gap: 10px;

    .userhome-profile-picture-container {
      position: relative;
      height: 90px;
      width: 90px;

      .userhome-profile-picture {
        object-fit: contain;
        border-radius: 6px;
      }

      .userhome-profile-lock-button {
        @extend %actionable-button;
        position: absolute;
        left: 0;
        bottom: 0;
      }

      .userhome-profile-settings-button {
        @extend %actionable-button;
        position: absolute;
        right: 0;
        bottom: 0;
      }
    }

    .userhome-profile-information {
      @extend %list;
      flex: 1;

      .userhome-profile-name {
        text-transform: capitalize;
        font-size: 1.2rem;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: space-between;
      }

      .userhome-profile-email {
        color: var(--color-gray-600);
        margin-top: -8px;
        font-size: 0.8rem;
      }

      .userhome-profile-action-button {
        @extend %actionable-button;
      }
    }
  }

  .userhome-directory {
    .userhome-directory-header {
      @extend %actionable-button;
      position: relative;
      display: grid;
      grid-template-columns: 1rem 1fr;
      align-items: center;

      .userhome-directory-header-collapse-button {
        @extend %actionable-button, %flex-centered;
        position: absolute;
        right: 0;
        height: 100%;
        aspect-ratio: 1 / 1;
      }
    }

    .userhome-directory-content {
      @extend %list;
      max-height: 0;
      overflow: hidden;
      transition: max-height 0.4s ease-in-out;

      &.userhome-directory-content-open {
        max-height: 200px;
        overflow: auto;
      }
    }
  }

  .userhome-seelen-options {
    @extend %list;
    .userhome-seelen-option-item {
      @extend %actionable-button;
    }
  }

  .userhome-power {
    margin-top: 4px;
    display: flex;
    gap: 6px;

    .userhome-power-button {
      @extend %actionable-button, %flex-centered;
      flex: 1;
      border: 1px solid var(--color-gray-600);
      border-radius: 8px;
      padding: 8px 12px;
    }
  }
}

.keyboard-selector {
  @extend %popup;

  .keyboard-selector-header {
    @extend %section-title;
  }

  .keyboard-selector-body {
    @extend %list;

    .keyboard-selector-entry {
      @extend %actionable-button;
      display: grid;
      grid-template-columns: 20px 1fr;
      align-items: center;
      gap: 10px;
      padding: 8px 10px;

      &.keyboard-selector-entry-active {
        background-color: rgba(var(--config-accent-color-rgb), 0.4);
      }

      .keyboard-selector-entry-info {
        display: flex;
        flex-direction: column;
        align-items: flex-start;

        .keyboard-selector-entry-lang {
          font-weight: 600;
          @extend %overflowable-text;
        }

        .keyboard-selector-entry-keyboard {
          font-size: 0.7em;
          line-height: 1.2em;
          font-weight: 600;
          color: var(--color-gray-600);
          @extend %overflowable-text;
        }
      }
    }
  }

  .keyboard-selector-footer {
    .keyboard-selector-footer-button {
      @extend %actionable-button;
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--color-gray-600);
    }
  }
}

.bluetooth {
  @extend %popup;

  .bluetooth-title {
    @extend %section-title;

    .bluetooth-refresh {
      @extend %actionable-button;
      .slu-icon {
        color: var(--color-gray-900);
        animation: rotate 1s linear infinite;
      }
    }
  }

  .bluetooth-entries {
    @extend %list;
    border-bottom: 1px solid var(--color-gray-300);
    padding-bottom: 10px;
    overflow-y: auto;
    max-height: 30vh;

    .bluetooth-entry {
      @extend %list;
      align-items: flex-end;
      padding: 12px 10px;
      border-radius: 8px;
      gap: 10px;

      &:hover {
        background-color: var(--color-gray-200);
      }

      &.bluetooth-entry-selected {
        background-color: rgba(var(--config-accent-color-rgb), 0.2);
      }

      .bluetooth-entry-info {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 8px;

        .bluetooth-entry-info-label {
          @extend %overflowable-text;
          flex: 1;
        }

        .bluetooth-entry-info-img {
          height: 1rem;
          width: 1rem;
          object-fit: contain;
          filter: invert(1);

          @media (prefers-color-scheme: dark) {
            filter: invert(0);
          }
        }
      }
    }

    .bluetooth-empty {
      @extend %flex-centered;
      height: 200px;
      font-style: italic;
    }
  }

  .bluetooth-footer {
    .bluetooth-footer-more-button {
      @extend %actionable-button;
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--color-gray-600);
    }
  }
}
